import random
import csv


def random_list(crease01):
    new_crease = [crease01[0] + random.uniform(-0.03, 0.03), crease01[1] + random.uniform(-0.02, 0.02),
                  crease01[2] + random.uniform(-0.02, 0.02), crease01[3] + random.uniform(-0.01, 0.01),
                  crease01[4] + random.uniform(-0.01, 0.01)]
    return new_crease


def random_sw(crease02):
    new_sw = [crease02[0] + random.uniform(-0.003, 0.003), crease02[1] + random.uniform(-0.002, 0.002),
              crease02[2] + random.uniform(-0.002, 0.002), crease02[3] + random.uniform(-0.001, 0.001),
              crease02[4] + random.uniform(-0.001, 0.001), crease02[5] + random.uniform(-0.001, 0.001)]
    return new_sw


if __name__ == '__main__':
    f = csv.reader(open('data0512.csv', 'r', encoding='utf-8'))
    f_list = []
    for i in f:
        f_list.append(i)
    crease1 = [0.4, 0.18, 0.08, 0.03, 0.01]
    crease2 = [0.45, 0.21, 0.09, 0.04, 0.02]
    crease3 = [0.50, 0.24, 0.12, 0.06, 0.02]
    sw = [1.01, 1.025, 1.035, 1.04, 1.043, 1.045]

    result = ["全风化"]
    for i in range(18):
        title = []
        crease = []
        result1 = []
        result2 = []
        result3 = []

        name = str(f_list[0][i])
        num1 = float(f_list[3][i])
        num2 = float(f_list[1][i])
        num3 = round(float(f_list[2][i])/100, 6)

        title.append(name)
        title.append(num1)
        title.append(num2)
        title.append(num3)

        crease_random = random_list(crease1)
        crease.append(num1)
        for j in range(5):
            crease.append(round(crease[j] + crease[j] * crease_random[j], 2))

        result1.append(num2)
        for k in range(6):
            result1.append(round(num2 * crease[k], 4))

        sw1 = random_sw(sw)
        for s in range(6):
            sw1[s] = round(sw1[s], 4)
        result3.append(num3)
        for p in range(6):
            result3.append(round(num3 * sw1[p], 6))

        for q in range(7):
            result2.append(round(result1[q] / result3[q], 4))
        result.append(title)
        result.append("增长倍数：")
        result.append(crease)
        result.append("泡水强度：")
        result.append(result1)
        result.append("未泡水强度：")
        result.append(result2)
        result.append("水稳系数增长倍数：")
        result.append(sw1)
        result.append("水稳系数：")
        result.append(result3)
        result.append('\n')

    result.append("强风化")
    for i in range(18):
        title = []
        crease = []
        result1 = []
        result2 = []
        result3 = []

        name = str(f_list[4][i])
        num1 = float(f_list[7][i])
        num2 = float(f_list[5][i])
        num3 = round(float(f_list[6][i]) / 100, 6)

        title.append(name)
        title.append(num1)
        title.append(num2)
        title.append(num3)

        crease_random = random_list(crease1)
        crease.append(num1)
        for j in range(5):
            crease.append(round(crease[j] + crease[j] * crease_random[j], 2))

        result1.append(num2)
        for k in range(6):
            result1.append(round(num2 * crease[k], 4))

        sw1 = random_sw(sw)
        for s in range(6):
            sw1[s] = round(sw1[s], 4)
        result3.append(num3)
        for p in range(6):
            result3.append(round(num3 * sw1[p], 6))

        for q in range(7):
            result2.append(round(result1[q] / result3[q], 4))
        result.append(title)
        result.append("增长倍数：")
        result.append(crease)
        result.append("泡水强度：")
        result.append(result1)
        result.append("未泡水强度：")
        result.append(result2)
        result.append("水稳系数增长倍数：")
        result.append(sw1)
        result.append("水稳系数：")
        result.append(result3)
        result.append('\n')

    result.append("中风化")
    for i in range(6):
        title = []
        crease = []
        result1 = []
        result2 = []
        result3 = []

        name = str(f_list[8][i])
        num1 = float(f_list[11][i])
        num2 = float(f_list[9][i])
        num3 = round(float(f_list[10][i]) / 100, 6)

        title.append(name)
        title.append(num1)
        title.append(num2)
        title.append(num3)

        crease_random = random_list(crease1)
        crease.append(num1)
        for j in range(5):
            crease.append(round(crease[j] + crease[j] * crease_random[j], 2))

        result1.append(num2)
        for k in range(6):
            result1.append(round(num2 * crease[k], 4))

        sw1 = random_sw(sw)
        for s in range(6):
            sw1[s] = round(sw1[s], 4)
        result3.append(num3)
        for p in range(6):
            result3.append(round(num3 * sw1[p], 6))

        for q in range(7):
            result2.append(round(result1[q] / result3[q], 4))
        result.append(title)
        result.append("增长倍数：")
        result.append(crease)
        result.append("泡水强度：")
        result.append(result1)
        result.append("未泡水强度：")
        result.append(result2)
        result.append("水稳系数增长倍数：")
        result.append(sw1)
        result.append("水稳系数：")
        result.append(result3)
        result.append('\n')

    with open("MakeFakeData.csv", 'w', newline='') as f:
        f_csv = csv.writer(f)
        for res in result:
            f_csv.writerow(res)
